<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('客户信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>商家名称：</label>
                            <input type="text" name="userName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="car:user:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="car:user:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="car:user:remove">
                <i class="fa fa-remove"></i> 删除
            </a>

            <button id="modalButton" type="button" style="display: none;" class="btn btn-primary" data-toggle="modal"
                    data-target="#myModal6">
            </button>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<div class="modal inmodal fade" id="myModal6" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">客户充值</h4>
            </div>
            <div class="modal-body">

                <form class="form-horizontal m" id="form-user-edit">
                    <input name="userId" type="hidden">
                    <div class="form-group">
                        <div class="col-sm-12  is-required">
                            <span id="userName" style="font-weight: bold;color: deepskyblue"></span> 充值金额：
                        </div>
                        <div class="col-sm-12 is-required">
                            <input name="money" placeholder="请输入充值金额" class="form-control" type="text" maxlength="30"
                                   required>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" id="closeModel" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="submitHandler();">保存</button>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('car:user:edit')}]];
    var removeFlag = [[${@permission.hasPermi('car:user:remove')}]];
    var sexDatas = [[${@dict.getType('sys_user_sex')}]];
    var highestdegreeDatas = [[${@dict.getType('sys_highestdegree')}]];
    var politicDatas = [[${@dict.getType('sys_common_politic')}]];
    var workstateDatas = [[${@dict.getType('sys_work_status')}]];
    var prefix = ctx + "system/user";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "客户信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'userName',
                    title: '商家名称'
                },
                {
                    field: 'remark',
                    title: '法人姓名'
                },

                {
                    field: 'loginName',
                    title: '登录账号'
                },
                // {
                //     field: 'sex',
                //     title: '性别',
                //     formatter: function (value, row, index) {
                //         return $.table.selectDictLabel(sexDatas, value);
                //     }
                // },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.delFlag == 0) {
                            actions.push('<a class="btn btn-danger btn-xs  " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>封禁</a>');
                        } else {
                            actions.push('<a class="btn btn-primary btn-xs  " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-shopping-bag"></i>上线</a>');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function payMoney(userId, userName) {
        $("input[name='userId']").val(userId);
        $("#userName").text(userName);
        $("#modalButton").click();

    }

    function submitHandler() {

        var money = $("input[name='money']").val();
        if (money <= 0) {
            $.modal.alertWarning("请输入充值金额");
            return;
        }

        $.operate.save(prefix + "/pay", $('#form-user-edit').serialize());
        $("input[name='money']").val("");
        $("#closeModel").click();
    }
</script>
</body>
</html>
